import akshare as ak

#======下面两行解决DataFrame打印时表头与数据不对齐的问题。====
import pandas as pd
pd.set_option('display.unicode.east_asian_width', True)
#=============================================================

# 获取平安银行（000001）的日K线数据
stock_zh_a_hist_df = ak.stock_zh_a_hist(symbol="000001", period="daily", 
                                        start_date="20200101", end_date='20200315', adjust="qfq")
# 打印结果
print(stock_zh_a_hist_df.tail(1))
#日期 股票代码   开盘   收盘  ...  振幅  涨跌幅  涨跌额  换手率


# 获取股票后复权数据
df = ak.stock_zh_a_hist(symbol="000001", period="daily", 
                        start_date="20200101", end_date='20200315', adjust="qfq")
# 处理字段命名
df = df[['日期','开盘', '收盘', '最高','最低', '成交量',]]
df.columns = ['date', 'open', 'close', 'high', 'low', 'volume']
# 将date设为索引
df.index = pd.to_datetime(df['date'])
print(df.tail(1))